package com.interview.javabasic.IO;

import java.io.IOException;
import java.net.Socket;
import java.util.Date;

/*
@李子宁
Happy,happy everyday!
冲鸭！
2021/2/28

*/
public class NIOClient {

    public static void main(String[] args) {
        try {
            Socket socket = new Socket("127.0.0.1",3333);
            new Thread(() ->{
                while(true){
                    try {
                        socket.getOutputStream().write((new Date() + ":hello word").getBytes());
                        Thread.sleep(2000);
                    } catch (IOException | InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }).start();
        } catch (IOException e) {



        }
    }
}
